<?php
// 在此文件中定义接口路由，定义在此的路由，请求PUT/POST/DELETE将不会有csrf验证
// 定义在此的路由规则，它都会默认添加一个访问的前缀，前缀名称默认为 api

/*use Illuminate\Http\Request;

// 实际的规则为  api/a
Route::any('login',function (Request $request){

    // laravel获取请求头信息
    // 获取所有的请求头信息
    #dump($request->header());
    // 指定获取对应的请求头信息
    dump($request->header('username'));
    dump($request->header('password'));


    return 'api/a路由规则';
});*/

// 日后此步骤在小程序中计算得到的，发起给后台
Route::get('test', function () {
    $username = 'user1';
    $password = 'user1';
    $token = 'token1';
//    $timestemp = 2324324324;
    $timestemp = time();

    return md5('admin');

    return $timestemp;
    // 生成签名
    $sign = md5($username . $password . $token . $timestemp);
    echo $sign;
});

Route::get('tests',function (){
    cache(['a'=>'aaaa'],1);
    return cache('a');
});

Route::group(['middleware' => ['checkapi'], 'namespace' => 'Api'], function () {
    // 后台小程序登录
    Route::post('login', 'LoginController@login');
    //小程序用户授权
    Route::post('auth','LoginController@auth');
    //租客资料
    Route::post('renting','RentingController@renting');
    //身份证图片上传
    Route::post('upfile','RentingController@upfile');
    //查看租客对应的通知信息
    Route::get('renting/notice','RentingController@notice');
    //根据id值获取租客资料
    Route::get('renting/{renting}','RentingController@show');
    //获取文章列表
    Route::get('articles','ArticleController@index');
    //获取文章详情信息
    Route::get('articles/{article}','ArticleController@show');
    //文章访问统计
    Route::post('articles/count','ArticleController@count');
    //推荐房源
    Route::get('fang/recommend','FangController@recommend');
    //房源属性
    Route::get('fang/attr','FangController@attr');
    //房源列表
    Route::get('fangs','FangController@index');
    //看房记录添加
    Route::post('fangs/rec','FangController@rec');
    //看房记录列表
    Route::get('fangs/rec','FangController@recList');
    //个人已租房源
    Route::get('fangs/rented','FangController@rented');
    //房源模糊搜索
    Route::get('fangs/search','FangController@search');
    //房源详情
    Route::get('fangs/{fang}','FangController@show');
    //添加收藏(记录租客id,房源id,入库操作)
    Route::post('favs','FavController@add');
    //查询当前租客是否收藏该房源
    Route::get('favs/bool','FavController@bool');
    //收藏房源获取
    Route::get('favs','FavController@index');
    //房源属性-快搜接口
    Route::get('attrs','FangAttrController@index');

    Route::get('jock','JockController@index');
});